package com.hao.tool.web.module.base.controller;

import com.hao.tool.common.entity.LayResponse;
import com.hao.tool.web.module.base.entity.ShortInfo;
import com.hao.tool.web.module.base.service.ShortInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * description
 *
 * @author RuiHaoZ on GZ.cmhk
 * @date 2019-11-22 23:37
 */
@RestController
@RequestMapping("/rest/s")
public class ShortRestController {
    @Autowired
    private ShortInfoService shortInfoService;

    @GetMapping("/info")
    public LayResponse findById(String shortId) {
        ShortInfo shortInfo = shortInfoService.getById(shortId);
        if (shortInfo == null) {
            return LayResponse.builder().code(404).msg("数据不存在").build();
        } else {
            return LayResponse.builder().code(200).data(shortInfo).build();
        }
    }

}
